
#include "Utils.h"
class RTPUnpacker
{
	typedef struct
    {  
        //LITTLE_ENDIAN  
        unsigned short   cc:4;      /* CSRC count                 */  
        unsigned short   x:1;       /* header extension flag      */  
        unsigned short   p:1;       /* padding flag               */  
        unsigned short   v:2;       /* packet type                */  
        unsigned short   pt:7;      /* payload type               */  
        unsigned short   m:1;       /* marker bit                 */  
  
        unsigned short    seq;      /* sequence number            */  
        unsigned long     ts;       /* timestamp                  */  
        unsigned long     ssrc;     /* synchronization source     */  
    } rtp_hdr_t; 

public:
	RTPUnpacker (unsigned char H264PAYLOADTYPE );

	~RTPUnpacker(void);
	void SetLostPacket()  ;
	char* Parse_RTP_Packet ( char *pBuf, unsigned short nSize, int *outSize )  ;

	private:  
    rtp_hdr_t m_RTP_Header ;  
  
    char *m_pBuf ;
  
    bool m_bSPSFound ;  
    bool m_bWaitKeyFrame ;  
    bool m_bAssemblingFrame ;  
    bool m_bPrevFrameEnd ;  
    char *m_pStart ;
    char *m_pEnd ;
    int m_dwSize ;
  
    int m_wSeq ;
  
    char m_H264PAYLOADTYPE ;
    int m_ssrc ;

	int receivedPacket;
	int lostPacket;
};

